package com.wzh.store.utils;

import java.io.Serializable;

/**
 * @Author wzh
 * @create 2022/4/11 21:15
 * 创建响应
 * 状态码，状态描述信息，数据，这部分功能封装在一个类中，将这个类作为方法的返回值，返回给前端浏览器
 * json格式的数据进行响应
 */
public class JsonResult<E> implements Serializable {
//    状态码
    private Integer state;
//    描述信息
    private String message;
//    数据
    private E data;

    public JsonResult(Integer state, String message, E data) {
        this.state = state;
        this.message = message;
        this.data = data;
    }

    public JsonResult(Integer state) {
        this.state = state;
    }

    public JsonResult(String message) {
        this.message = message;
    }
    public JsonResult() {

    }
    public JsonResult(Throwable e) {
        this.message = e.getMessage();
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    public JsonResult(Integer state, String message) {
        this.state = state;
        this.message = message;
    }

    public JsonResult(Integer state, E data) {
        this.state = state;
        this.data = data;
    }
}
